package org.rcy.ruicingmarket.file.store;

import com.qiniu.common.QiniuException;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.Region;
import com.qiniu.util.Auth;

public class QiNiuYunFileDeleteUtils {
public static boolean deleteImg(String imgName)
    {
        //构造一个带指定 Region 对象的配置类
        Configuration cfg = new Configuration(Region.region0());
//...其他参数参考类注释
        String accessKey = "fEw6-GWFbII0boLfcxs8cokl1UUBbLKdnN1wuk5n";
        String secretKey = "BkVO4gEmPcdWuMgiwwleld_iVbZOjGq1pwGRFxD2";
        String bucket = "rcystock";
        String key = imgName;
        Auth auth = Auth.create(accessKey, secretKey);
        BucketManager bucketManager = new BucketManager(auth, cfg);
        try {
            bucketManager.delete(bucket, key);
            return true;
        } catch (QiniuException ex) {
            //如果遇到异常，说明删除失败
            System.err.println(ex.code());
            System.err.println(ex.response.toString());
            return false;
        }
    }
}
